package {
    import away3d.core.material.*;
    import away3d.core.math.Number3D;
    import away3d.core.render.*;
    import away3d.core.scene.*;
    import away3d.loaders.*;
    import away3d.objects.*;
    
    import flash.display.*;
    import flash.events.*;
    
    
    public class ClockDaeTest extends Sprite
    {
        public var view:View3D;
        public var object:Object3DLoader;
        
        /**
         * Constructor
         */
        public function ClockDaeSTest():void
        {
            //setup stage
            
            //setup view
            view = new View3D();
            addChild(view);
            
//            object = Max3DS.load("../model/jeep1.3ds", {texturePath:"../model/", name:"jeep", loadersize:100});
            object = Collada.load("models/bradleycollectionconsole.dae");
             
            view.scene.addChild(object);
            
            //setup listeners
			addEventListener(Event.ENTER_FRAME,go);
        }
        
        private var down:Boolean = false;
		private function press(e:MouseEvent3D):void {
			down = true;
		}
		private function go(event:Event):void{
			view.render(); 
		}
		private function mv(e:MouseEvent3D):void{
			if(down){
				object.x = e.sceneX;
				object.z = e.sceneZ;
			}
		}
		private function up(e:MouseEvent3D):void{
			down = false;
		}
       
        private function initObject(event:Event):void
        {
            //scale
            //adjust internal coords
            (object as ObjectContainer3D).movePivot((object.maxX + object.minX)/2, (object.maxY + object.minY)/2, (object.maxZ + object.minZ)/2);
            //recenter
            object.x = object.y = object.z=0;
//            object.handle.x = object.handle.y = object.handle.z = 0;
        }
        
        /**
         * resize handler
         */        
        private function onResize(event:Event):void
        {
            view.x = stage.stageWidth/2;
            view.y = stage.stageHeight/2;
        }
        
      
    }
}